<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>员工工资折线图</title>
    <!-- 引入 ECharts 文件 -->
    <script src="https://cdn.bootcdn.net/ajax/libs/echarts/5.3.3/echarts.min.js"></script>
</head>
<body>
<!-- 为ECharts准备一个具备大小（宽高）的Dom -->
<div id="main" style="width: 600px;height:400px;"></div>

<script type="text/javascript">
    // 初始化echarts实例
    var myChart = echarts.init(document.getElementById('main'));

    // 使用Ajax获取数据
    function fetchData() {
        var xhr = new XMLHttpRequest();
        xhr.onreadystatechange = function () {
            if (xhr.readyState == 4 && xhr.status == 200) {
                var jsonData = JSON.parse(xhr.responseText);
                var option = {
                    xAxis: {
                        type: 'time',
                        splitLine: {
                            show: false
                        }
                    },
                    yAxis: {
                        type: 'value',
                        boundaryGap: [0, '30%']
                    },
                    series: [{
                        data: jsonData.data,
                        type: 'line',
                        smooth: true
                    }]
                };
                myChart.setOption(option);
            }
        };
        xhr.open("GET", "xz.php", true); // php文件路径
        xhr.send();
    }

    // 调用函数获取数据
    fetchData();
</script>
</body>
</html>